package io.renren.modules.course.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.course.entity.CompanyPostionEntity;
import io.renren.modules.course.service.CompanyPostionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 公司职位
 *
 * @author zlb
 * @email 316682546@qq.com
 * @date 2018-08-09 08:55:58
 */
@RestController
@RequestMapping("course/companypostion")
public class CompanyPostionController {
    @Autowired
    private CompanyPostionService companyPostionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("course:companypostion:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = companyPostionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("course:companypostion:info")
    public R info(@PathVariable("id") Integer id){
        CompanyPostionEntity companyPostion = companyPostionService.selectById(id);

        return R.ok().put("companyPostion", companyPostion);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("course:companypostion:save")
    public R save(@RequestBody CompanyPostionEntity companyPostion){
        companyPostionService.insert(companyPostion);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("course:companypostion:update")
    public R update(@RequestBody CompanyPostionEntity companyPostion){
        ValidatorUtils.validateEntity(companyPostion);
        companyPostionService.updateAllColumnById(companyPostion);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("course:companypostion:delete")
    public R delete(@RequestBody Integer[] ids){
        companyPostionService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
